package com.yunupmall.controller.amdin;

import com.yunupmall.api.fordentity.Image;
import com.yunupmall.service.admin.service.ImageService;
import com.yunupmall.uits.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/image")
@AllArgsConstructor
public class ImageController {
    private final ImageService imageService;
    private final Result result;


    @GetMapping("/getList")
    public Result<Image> getList() {
        try {
            return result.ok(imageService.getList());
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

    @PostMapping("/update")
    public Result<String> updateData(@RequestBody Image image){
        try {
            return result.ok(imageService.updateData(image));
        }catch (Exception e) {
            return result.error(e.getMessage());
        }
    }

}
